#include "TrackSaver.h"
#include "model/Point.h"

bool TrackSaver::save(const char* fileName, Track& t) {
	vector<Point>& points = *t.getPoints();
	ofstream fout;
	fout.open(fileName, ios::out);
	if (!fout) {
		std::cout << "Unable to open save " << fileName << "\n";
		return false;
	} else {
		unsigned n = points.size();
		fout << n << "\n";
		for (size_t i = 0; i < n; i++) {
			fout << points[i].x;
			fout << " ";
			fout << points[i].y;
			fout << "\n";
		}
		fout.close();
		return true;
	}
}
